package com.ruoyi.project.report.car.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

import com.ruoyi.common.utils.DateUtils;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.lease.car.domain.Car;
import com.ruoyi.project.report.car.domain.CarReport;
import com.ruoyi.project.report.car.service.ICarReportService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 车辆报表Controller
 *
 * @author admin
 * @date 2021-01-17
 */
@Controller
@RequestMapping("/report/car")
public class CarReportController extends BaseController{
    private String prefix = "report/car";

    @Autowired
    private ICarReportService carReportService;

    @RequiresPermissions("report:carReport:view")
    @GetMapping()
    public String car()
    {
        return prefix + "/car_report";
    }


    /**
     * 查询车辆统计报表列表
     */
    @RequiresPermissions("report:carReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CarReport carReport)
    {
        startPage();
        List<CarReport> carList = carReportService.selectCarReports(carReport);

        return getDataTable(carList);
    }

    /**
     * 导出车辆报表
     */
    @RequiresPermissions("report:carReport:export")
    @Log(title = "车辆统计报表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CarReport carReport)
    {
        List<CarReport> list = carReportService.selectCarReports(carReport);
        ExcelUtil<CarReport> util = new ExcelUtil<CarReport>(CarReport.class);
        return util.exportExcel(list, "车辆统计报表数据");
    }

}
